<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="Cache-Control" content="no-siteapp">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=1, minimum-scale=1, maximum-scale=1">
<meta name="renderer" content="webkit">
<meta name="google" value="notranslate">
<meta name="robots" content="index,follow">


<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="足迹">
<meta name="twitter:description" content="走过就要留下点什么">
<meta name="twitter:image:src" content="http://wenjq.gitee.io/images/avatar.jpg">

<meta property="og:url" content="http://wenjq.gitee.io">
<meta property="og:title" content="足迹">
<meta property="og:description" content="走过就要留下点什么">
<meta property="og:site_name" content="足迹">
<meta property="og:image" content="http://wenjq.gitee.io/images/avatar.jpg">
<meta property="og:type" content="website">
<meta name="robots" content="noodp">

<meta itemprop="name" content="足迹">
<meta itemprop="description" content="走过就要留下点什么">
<meta itemprop="image" content="http://wenjq.gitee.io/images/avatar.jpg">

<link rel="canonical" href="http://wenjq.gitee.io">

<link rel="shortcut icon" href="/favicon.png">
<link rel="apple-itouch-icon" href="/favicon.png">
<link rel="stylesheet" href="/bundle/index.css">
<script type="text/javascript">
    var timeSinceLang = {
        year: '年前',
        month: '个月前',
        day: '天前',
        hour: '小时前',
        minute: '分钟前',
        second: '秒前'
    };
    var root = '';
</script>


        <meta name="keywords" content="maven,">
        <meta name="description" content="Maven安装及配置">
        <meta name="author" content="">
        <title>Maven安装及配置</title>
    </head>
    <body>
        <article class="container">
            <header class="header-wrap">
  <a class="index" href="/">
    <img class="logo" src="/images/avatar.jpg" />
    足迹
  </a>
  <ul class="menu">
      <li class="menu-item"><a href="/archive.html">归档</a></li>
      <li class="menu-item"><a href="/tag.html">标签</a></li>
      <li class="menu-item"><a href="/atom.xml">订阅</a></li>
  </ul>
</header>

            <article class="main article">
                <h1 class="title">Maven安装及配置</h1>
                <section class="info">
                    
                    
                    
                    <span class="date" data-time="1483942401"><span class="from"></span></span>
                    
                    <span class="tags"><a class="tag" href="/tag/maven/index.html">maven</a></span>
                </section>
                <article class="content"><h2>必备条件</h2>

<ul>
<li>JDK（Maven 3.2 要求 JDK 1.6 或以上版本, 而 Maven 3.0/3.1 需要 JDK 1.5 或以上）</li>

<li><p>Maven包（<a href="http://maven.apache.org/）下载。">http://maven.apache.org/）下载。</a></p>

<h2>安装及环境变量配置</h2></li>

<li><p>安装JDK（过程略）</p></li>

<li><p>解压下载到的 maven.zip 文件到任意的目录（英文目录）</p></li>

<li><p>打开环境变量配置，新建环境变量  M2_HOME 值为maven的根目录。注意：Maven官方手册为M2_HOME,但人有一些项目使用       MAVEN_HOME,因此这里可添加两个。</p></li>

<li><p>验证命令行输入 mvn -version 成功后将显示maven版本及jdk相关信息。
<img src="" data-src="/images/20180530144039672.png" alt="" /></p>

<h2>使用前的准备</h2>

<h3>配置jar包仓库地址。</h3>

<p>maven默认会将jar包仓库 .m2 文件夹建于当前登录用户的文档下，如果需要自定义仓库地址，则只要修改 /maven_home/conf 下的setting.xml文件。
找到 localRepository 节点配置进行自定义配置。如
<img src="" data-src="/images/20180530144103683.png" alt="" /></p>

<h3>配置中央仓库镜像</h3>

<p>由于maven默认的中央仓库在国外，因此国内访问等于龟速。因此我们可以配置maven访问国内的中央仓库镜像，比如这里配置使用阿里云的中央仓库。
同样在setting.xml文件中找到mirrors节点，在节点下添加
<img src="" data-src="/images/2018053014412252.png" alt="" /></p>

<h2>配置IDE</h2>

<h3>eclipse的配置</h3>

<p>打开eclipse后点击window-&gt;preferences-&gt;Maven-&gt;User Settings
<img src="" data-src="/images/20180530144140423.png" alt="" />
配置User settings选择maven目录下修改后的settings.xml后其他目录的配置xml。保存即可。
再次打开window-&gt;preferences-&gt;Maven-&gt;Installations
<img src="" data-src="/images/20180530144201698.png" alt="" />
点击右侧的Add选择Maven的根目录并保存，这里为初始化配置，无需选择Project
<img src="" data-src="/images/20180530144213405.png" alt="" /></p>

<h3>intellij idea的配置</h3>

<p>打开intellij idea后一次点击File-&gt;Other Setting-&gt;Default Settings-&gt;Build,Execution,Deploment-&gt;Build Tools-&gt;Maven
勾选User Setting files后的Override后，选择maven目录下修改后的setting.xml 保存即可
<img src="" data-src="/images/20180530144232952.png" alt="" /></p></li>
</ul>
</article>
                <section class="author">
                    
                    <a class="name" href="/about..html"></a>
                    <div class="intro"></div>
                </section>
                <section class="recommend">
                    
                    <section class="nav prev more">
                        <div class="head">上篇文章</div>
                        <a class="link" href="/2018053001.html">Maven的使用</a>
                    </section>
                    
                    
                    <section class="nav next more">
                        <div class="head">下篇文章</div>
                        <a class="link" href="/2018053002.html">Maven使用jar包管理js和css库</a>
                    </section>
                    
                </section>
                

            </article>
        </article>
        <footer class="footer">
    <span class="copyright">
        足迹 ©
        <script type="text/javascript">
            document.write(new Date().getFullYear());
        </script>
    </span>
    <span class="publish">Powered by <a href="http://www.chole.io/" target="_blank">Ink</a></span>
</footer>

        <script src="/bundle/index.js"></script>
    </body>
</html>
